<!--采购协同-->
<template>
	<div class="m-view-masterMenu m-window">
		<div class="m-module" v-for="(item, index) in menu" :key="index">
			<div class="m-title">{{ item.title }}</div>
			<ul>
				<li
					v-for="(list, serial) in item.list"
					:key="serial"
					@click="addTab(list)"
					:class="{ 'm-completed': list.completed }"
				>
					<i :class="'iconfont icon-' + list.name"></i>
					<span>{{ list.cName }}</span>
				</li>
			</ul>
		</div>
	</div>
</template>

<script>
// import _APIS from "@/api";
// import constant from "@/public/constant";
import utils from "@/public/utils";
import authorize from "@/public/authorize";

export default {
	data () {
		return {
			menu: [
				{
					title: "采购协同",
					list: [
						// {
						// 	cName: "差异调整申请",
						// 	name: "goodsAccountBill2",
						// 	completed: true,
						// },
						// {
						// 	cName: "差异调整记录",
						// 	name: "adjustBill",
						// 	completed: true,
						// },
						// {
						// 	cName: "合同管理",
						// 	name: "contractManager",
						// 	completed: true,
						// },
						// {
						// 	cName: "未发布订单列表",
						// 	name: "unPublishedPurOrder",
						// 	completed: true,
						// 	flag: "unpublished",
						// },
						// {
						// 	cName: "已发布订单列表",
						// 	name: "publishedPurOrder",
						// 	completed: true,
						// 	flag: "published",
						// },
						// {
						// 	cName: "创建送货计划",
						// 	name: "createDeliveryPlan",
						// 	completed: true,
						// },
						// {
						// 	cName: "送货计划列表",
						// 	name: "deliveryPlanList",
						// 	completed: true,
						// },
						// {
						// 	cName: "需求计划列表",
						// 	name: "demandPlanList",
						// 	completed: true,
						// },
					],
				},
			],
		};
	},
	props: {
		addTab: {
			type: Function,
		},
	},
	methods: {
		getMenuDetails () {
			let parentId = utils.getMenuId("menuId"); // 菜单ID
			let activeMenu = [];
			authorize.getMenuAuth(parentId).then((res) => {
				if (Array.isArray(res) && res.length > 0) {
					this.menu.forEach((menu, index) => {
						activeMenu.push({
							title: menu.title,
							list: [],
						});
						res.forEach((item) => {
                            activeMenu[index].list.push({
                                name: item.code,
                                cName: item.name,
                                completed: true,
                            });
						});
					});
					this.menu = activeMenu;
				}
			});
		},
	},
	components: {},
	beforeMount () {
		this.getMenuDetails();
	},
};
</script>

<style></style>
